package models

import "gorm.io/gorm"

type Good struct {
	gorm.Model
	UserId         int64   `gorm:"type:int;not null;commit:'用户Id'"`
	Title          string  `gorm:"type:varchar(155);not null;commit:'商品标题'"`
	Stock          int     `gorm:"type:int;not null;commit:'商品库存'"`
	TypeId         int     `gorm:"type:int;not null;commit:'商品分类'"`
	Price          float64 `gorm:"type:decimal(10,2);not null;commit:'商品价钱'"`
	Image          string  `gorm:"type:varchar(155);not null;commit:'商品封面'"`
	Status         int     `gorm:"type:int;not null;default:0;commit:'商品状态 0-上架,1-下架'"`
	CheckoutStatus int     `gorm:"type:int;not null;default:0;commit:'商品审核状态 0-审核通过,1-审核失败,2-待审核'"`
	LookId         int     `gorm:"type:int;not null;commit: 浏览量Id'"`
}

func (g *Good) Detail() error {
	return DB.Where("status=0 and checkout_status=0").First(&g).Error
}

type GoodInfo struct {
	Title string
	Stock int
	Name  string
	Image string
	Num   int64
	Phone string
	Price float64
}
